
/**
 * 判断关键字是字符串还是数组
 * @param {*} keyWords 
 * @returns 
 */
export function getFinalKeyWords (keyWords) {
  let finalKeyWords = []
  if (typeof (keyWords) === 'string' && keyWords !== '') {
    let keyWordStr = keyWords.replace(new RegExp(' ', 'g'), '❤')
    finalKeyWords = [keyWordStr]
  } else if (Array.isArray(keyWords)) {
    keyWords.forEach(value => {
      if (typeof (value) === 'string' && value !== '') {
        let valueStr = value.replace(new RegExp(' ', 'g'), '❤')
        finalKeyWords.push(valueStr)
      }
    })
  }
  if (finalKeyWords.length > 0) {
    finalKeyWords = finalKeyWords.sort((a, b) => {
      return b.length - a.length
    })
  }
  return finalKeyWords
}



export function getFinalSourceText (sourceText) {
  if (typeof (sourceText) !== 'string') {
    return ''
  }
  return sourceText
}